Serial advanced technology attachment (SATA) disk drives use a rigid 512-bytes per sector format, however, many applications require a larger block size e.g. 520-byte, 524-byte, 528-byte, etc. Thus, to use SATA drives with these application requires a conversion process in which the larger block sizes are “mapped” across a number of 512-byte SATA sectors. Well-known mapping algorithms arrange the larger “logical” blocks across contiguous 512-byte “physical” sectors, so that each logical block will start and end at some offset into a physical sector. When logical blocks are being accessed by the application, it is necessary to calculate the physical sectors which contain the required logical blocks, and also the offsets which mark the start and end of the logical blocks within the physical sectors. For read accesses, it is a simple matter to locate and read the appropriate physical sectors, then discard the “unwanted” data, i.e., data before the starting offset or after the ending offset. However for write accesses it is not possible to simply discard the “unwanted” data, because that data belongs to adjacent logical blocks and must not be altered when the physical sectors are written. Thus, for write operations it is necessary to first read the required physical sectors, then modify only the portion of those sectors which represent the logical blocks being written, and then write the physical sectors back to the media, This read/modify/write process (r/m/w) is a known feature in disk drive architecture, and is currently implemented in many applications.
A drawback to the current r/m/w operation is that a power loss during the r/m/w operation can cause unrecoverable data loss. This possibility occurs during every r/m/w operation, at the point where the two part-modified sectors at the start and end of the logical blocks (i.e., the “boundary” sectors) are being written to the media. If the storage system suffers a power failure while the disk drive is writing one of the boundary sectors, that sector will be corrupted, which results in the data from two different logical blocks being corrupted. For one of these logical blocks (the one which was being written by the application), this is a recoverable situation because the application will have retained a copy of the data being written, and can save it elsewhere if it does not receive a confirmation from the storage system. However, for the other logical block there is no such recovery. The application was not involved in writing that logical block and does not hold a copy of its data, and thus, that data is lost.
There are several methods of avoiding the potential problem, but all have drawbacks and disadvantages. Most methods rely on detecting the “imminent power loss warning” provided by the system. Typically, this warning alerts devices that they have only a few milliseconds to complete vital operations before power is lost. A SATA adapter which has just issued a r/m/w operation to the drive cannot know if that write will complete in the time available, so it must assume that data on the media may become corrupted as described above. The SATA adapter will use the available time to save data which is exposed, but to save the two boundary sectors in non-volatile memory (i.e. 1024 bytes) requires more time than is available before power loss, so the SATA adapter cannot guarantee to save the exposed data. To be certain of avoiding this exposure, the SATA adapter may save the boundary sectors to nonvolatile memory on every r/m/w operation, however, this adds a long delay in the r/m/w process and substantially reduces the write performance. Another solution uses battery backup systems which allow current write operations to complete if the main system power is lost, however, this is very expensive to implement, and significantly reduces the cost benefits of using SATA drives.
Therefore, it would be desirable to provide a r/m/w operation which guarantees boundary data cannot be lost due to a power loss event. It would further be desirable for the operation to be inexpensive to implement (since a main benefit of using SATA drives is the relatively low cost), and be efficient in operation (since there is already a performance penalty imposed by the standard r/m/w process, a further performance penalty would be undesirable).